﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jogo
{
    class MainCodeToImport
    {

        /*NOT YET IMPORTED
         * 
         /*************************************************************
*************	Codes by Gabriel de Araujo 	******************
*************	Silva Rego AkA Ironbull		******************
*************************************************************/

/************** LIBRABRIES 

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;


/************** EVENT LISTENERS
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPRESSED);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyRELEASED);
stage.addEventListener(Event.ENTER_FRAME, REFRESH);

youwin.visible = false;
youlose.visible = false;

/************** VARIABLE DECLARATION 
var distance	: int			;
var ToClock		: int 		= 60;
var hitcount	: int			;
var enemy_HP	: int		= enemyhb.width;
var player_HP	: int		= playerhb.width;
var LOSS_COUNT	: int			;
var WIN_COUNT	: int			;

var BLOCK		: Boolean		;	
var DIRECTION	: Boolean	= true;
var RIGHT		: Boolean		;
var LEFT 		: Boolean		;
var RIGHT_e 	: Boolean		;
var LEFT_e 		: Boolean		;
var KICK 		: Boolean		;
var SPECIAL		: Boolean		;
var PUNCH 		: Boolean		;
var played	 	: Boolean		;
var STOP		: Boolean		;
var STOP_E		: Boolean		;
var E_FLY		: Boolean		= false;
var P_FLY		: Boolean     	;

/************* MUSIC DECLARATIONS
var sound_hit		: atingido 	 = new atingido();

var sound_action		: Soco 	 = new Soco();

var musica_f3		: Sound 	 = new Sound();
musica_f3.load(new URLRequest("tema_fundo2.mp3"));
musica_f3.play(0,int.MAX_VALUE);

/************* Code For Timers
var tmr 		: Timer		 = new Timer (1000);
var hitcounter	: Timer		 = new Timer (1000);



tmr.addEventListener(TimerEvent.TIMER, Clock);
hitcounter.addEventListener(TimerEvent.TIMER, HITCOUNTER);

					function Clock (e : TimerEvent) :void{
	if(ToClock>0){
		ToClock		-=1;
	}
}
					function HITCOUNTER (e:TimerEvent): void{
	if(PUNCH){
		return;
	}
	hitcount	=0;
}
/************ CODES FOR PLAYER  		**********
        /*
					function KeyPRESSED(e : KeyboardEvent) : void {
	
	if(e.keyCode == Keyboard.RIGHT) {
		if(!RIGHT && !BLOCK) {
			player.MoveToRight();
			RIGHT 	= true;
		}
	} else if(e.keyCode == Keyboard.LEFT) {
		if(!LEFT && !BLOCK) {
			player.MoveToLeft();
			LEFT 	= true;
		}
	} else if(e.keyCode == Keyboard.DOWN) {
		if(!LEFT && !RIGHT) {
			player.Block();
			BLOCK 	= true;
		}
	} else if(e.keyCode == Keyboard.Q && !GlobalVars.Playing) {
		if(!KICK) {
			player.Kick();
			KICK 	= true;
			sound_action.play();
		}
	} else if(e.keyCode == Keyboard.W && !GlobalVars.Playing) {
		if(!SPECIAL) {
			player.Special();
			SPECIAL = true;
			sound_action.play();
		}
	} else if(e.keyCode == Keyboard.E && !GlobalVars.Playing) {
		if(!PUNCH) {
			player.Punch();
			PUNCH 	= true;
			sound_action.play();
		}
	}
}


					function KeyRELEASED(e : KeyboardEvent) : void {
	
	if(e.keyCode == Keyboard.RIGHT) {
		RIGHT 		= false;
		player.Stop();
		
	} else if(e.keyCode == Keyboard.LEFT) {
		LEFT 		= false;
		player.Stop();
	} else if(e.keyCode == Keyboard.DOWN) {
		BLOCK 		= false;
		player.Stop();
	} else if(e.keyCode == Keyboard.Q) {
		KICK 		= false;
		player.Stop();
		
	} else if(e.keyCode == Keyboard.W) {
		SPECIAL 	= false;
		player.Stop();
	} else if(e.keyCode == Keyboard.E) {
		PUNCH 		= false;
		player.Stop();
	}
	
}
/************** END PLAYER CODES 		**********





/************** START COMPUTER CODES 	**********



/************** ENEMY 
							function AI():void{
			
	var block		: int			= 31;
	var punch		: int 			= 32;
	var kick		: int 			= 33;
	var special		: int			= 30;
	var action		: int			;
	var MOVE 		: int			= 1;
	var dice 		: int			;
	var movement	: int			;
	LEFT_e			= false;
	RIGHT_e			= false;
	DIRECTION=true;
	if(!enemy_.hitTestObject(player)){
		action 		=Math.round(Math.random() * 150);
		dice 		=Math.round(Math.random() * 3);
		movement	=Math.round(Math.random() * 4);
/*************** If the first die (action) does not land on 30 it will move towards player
**************** While if the second die (dice) does not land on 1 it will not move at all
**************** Third die if for which direction computer will go where there is a 25% 
**************** chance he will back up.
**************
		if (movement==1){
			DIRECTION			=false;
		}
		if(dice==MOVE){					// CALL TO SECOND DICE
			if(action!=special){ 		// CALL TO FIRST DICE
				if(DIRECTION==true){
					enemy_display.MoveToLeft();
					LEFT_e 		= true;
				}
				if (DIRECTION==false){
					enemy_display.MoveToRight();
					RIGHT_e 	= true;
				}
			}
		}
	}else if(enemy_.hitTestObject(player)){
		action=Math.round(Math.random() * 80);
		if(action==special){
			enemy_display.Special();
		}
		if(action==kick){
			enemy_display.Kick();
		}
		if(action==punch){
			enemy_display.Punch();
			
		}
		if(action==block){
			enemy_display.Block();
		}
	}
/******** END ENEMY
/******** End AI code********
}
							function AI_move():void{

		
							}
//******** END COMPUTER CODES
player_1.visible=false;
player_2.visible=false;
enemy_1.visible=false;
enemy_2.visible=false;

function WIN_tracker():void{
	if(enemy_HP<3){
		WIN_COUNT+=1;
		if(WIN_COUNT==1){
			player_1.visible=true;
		}
	}else if(enemy_HP<3){
		WIN_COUNT+=1;
		if(WIN_COUNT==2){
			player_2.visible=true;
		}
	}else if(player_HP<3){
		LOSS_COUNT+=1;
		if(LOSS_COUNT==1){
			enemy_1.visible=true;
		}
	}else if(player_HP<3){
		LOSS_COUNT+=1;
		if(LOSS_COUNT==2){
			enemy_2.visible=true;
		}
	}
}



					function REFRESH(e:Event):void{
//************ OUTSIDE SCREEN CHECKER ****
	STOP				= false ;
	STOP_E				= false ;
	if(player.hitTestObject(left_border)){
	   STOP				= true	;
	   player.x			+= 1 ;
	 }
	
	if(enemy.hitTestObject(right_border)){
	   STOP_E				= true	;
	   enemy.x			-= 7 	;
	   enemy_.x			-=	7	;
	   enemy_display.x	-=	7	;
	 }
	  


//************ TIMER CODE ****************
	time.text			=String(ToClock);
	tmr.start();

//************ CODE FOR ENEMY ************

		


//************** CALLS AI FUNCTION TO WORK ITS MAGIC*****
	AI(); 
	//MOVEMENT START
	/*if(!STOP_E){
		if(LEFT_e) {
			if(!(enemy_.hitTestObject(player))){
				enemy_display.x-=10;
		  		enemy.x-=10;
			}			
		}else if(RIGHT_e) {
			enemy_display.x+=10;
			enemy.x+=10;
		}
	}* /
	if(!enemy_.hitTestObject(player_)){
		enemy.x-=10;
		enemy_display.x-=10;
		enemy_.x-=10;
	}
	//END MOVEMENT	
	
/*************** CODE FOR PLAYER**********
	/ MOVEMENT START
	if(!STOP){
		if(LEFT) {
			player_.x-=10;
		}else if(RIGHT) {
			if(!(player_.hitTestObject(enemy_))){
				
				player_.x+=10;
			}
		}
	}
	if(enemyhb.width<=6){
		enemyhb.visible=false;
		youwin.visible=true;
		enemy_display.gotoAndStop(76);
		player.gotoAndStop(1);
		gameover();
	}
	
	if(playerhb.width<=6){
		playerhb.visible=false;
		youlose.visible=true;
		enemy_display.gotoAndStop(75);
		player.gotoAndStop(13);
		gameover();
	}
	if((enemyhb.width<playerhb.width) && (ToClock==0)){
		enemyhb.visible=false;
		youwin.visible=true;
		enemy_display.gotoAndStop(76);
		player.gotoAndStop(1);
		gameover();
	}
	
	if((playerhb.width<enemyhb.width)&& (ToClock==0)){
		playerhb.visible=false;
		youlose.visible=true;
		enemy_display.gotoAndStop(75);
		player.gotoAndStop(13);
		gameover();
	}
	
	// END MOVEMENT
	// TESTING CODE
	
	if((player.currentFrame==50)||(player.currentFrame==60)||(player.currentFrame==70)){
		GlobalVars.Played=true;
	}
	if((enemy_display.currentFrame==16)||(enemy_display.currentFrame==29)||(enemy_display.currentFrame==40)){
		GlobalVars.E_Played=true;
	}
	
	if((player.hitTestObject(enemy)) && (GlobalVars.Played) && !(enemy_display.currentFrame==9)){
		enemyhb.width-=33;
		enemy_display.gotoAndPlay(4);
		sound_hit.play();
		GlobalVars.Played=false;
		if(player.currentFrame==50){
			E_FLY=true;
		}
	}
	if(E_FLY){
		if(enemy.x<200){
			enemy_display.x+=35;
			enemy.x+=35;
			enemy_.x+=35;
			enemy_display.gotoAndStop(52);
		}
	}
	if(E_FLY && enemy.x>=200){
		enemy_display.gotoAndStop(54);
		E_FLY=false;
	}
	if((enemy_.hitTestObject(player)) && (GlobalVars.E_Played) && !(player.currentFrame==39)){
		playerhb.width-=33;
		sound_hit.play();
		//player.gotoAndPlay(2);
		GlobalVars.E_Played=false;
		if(enemy_display.currentFrame==28){
			P_FLY=true;
		}
	}
	if (P_FLY){
		if(player.x>40){
			player.x-=35;
			gotoAndPlay(7);
		}else if(player.x==40){
			P_FLY=false;
				 }
	}
	player.x=player_.x
	 enemy_HP	= enemyhb.width;
	 player_HP	= playerhb.width;
	// WIN_tracker();
	
}
function gameover ():void{
	
	stage.removeEventListener(KeyboardEvent.KEY_DOWN, KeyPRESSED);
	stage.removeEventListener(KeyboardEvent.KEY_UP, KeyRELEASED);
	stage.removeEventListener(Event.ENTER_FRAME, REFRESH);
	stage.addEventListener(KeyboardEvent.KEY_DOWN,restart);

}
function restart(e:KeyboardEvent):void{
	if(e.keyCode == Keyboard.R) {
		gotoAndStop(1);
	}
}

*/



    }
}
